#include "key.h"
int scan_key()
{
	if(key01 == 0)
	{Delay1ms(20);
		if(key01 == 0) return 1;
	}
	if(key02 == 0)
	{Delay1ms(20);
		if(key02 == 0) return 2;
	}
	if(key03 == 0)
	{Delay1ms(20);
		if(key03 == 0) return 3;
	}
	if(key04 == 0)
	{Delay1ms(20);
	if(key04 == 0) return 4;
	} return 0;
}
//矩阵键盘扫描函数
int scan_key_1()
{
	//static int key = 16;
		int key = 16;
		P3 = 0xF0;
		if(P3 != 0xF0)
	{
			Delay1ms(20);
			if(P3 != 0xF0)
		{
				if(P3 ==0xE0) key = 0;
				if(P3 ==0xD0) key = 1;
				if(P3 ==0xB0) key = 2;
				if(P3 ==0x70) key = 3;
			
			P3 = 0x0F;
			
				if(P3 ==0x0E) key = key + 0;
				if(P3 ==0x0D) key = key + 4;
				if(P3 ==0x0B) key = key + 8;
				if(P3 ==0x07) key = key + 12;
		}
		while(P3 != 0x0F);
	}
	return key;


}